home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / st80_pr4.lha / st80_pre4 / Foible / foible / PopUpNotifier.st < prev   
Text File  |  1993-07-24  |  2KB  |  100 lines

  1. 'From Tektronix Smalltalk-80 version T2.2.0cM3, of September 21, 1987 on 25 July 1988 at 5:13:44 pm'!
  2.  
  3. PopUpMenu subclass: #PopUpNotifier
  4.     instanceVariableNames: ''
  5.     classVariableNames: 'Boundary Heading '
  6.     poolDictionaries: ''
  7.     category: 'Accessories'!
  8.  
  9.  
  10. !PopUpNotifier methodsFor: 'controlling'!
  11.  
  12. startUp: aSymbol
  13.     "Display and make a selection from the receiver as long as the button
  14.     denoted by the symbol, aSymbol, is pressed.  Answer the current selection."
  15.  
  16.     | done |
  17.  
  18.     done _ false.
  19.     
  20.     self displayAt: Sensor cursorPoint
  21.         during: [Sensor cursorPoint: marker center.
  22.                     Sensor waitNoButton.
  23.             [done] whileFalse: [
  24.                 (self buttonPressed: aSymbol)
  25.                     ifFalse: [(frame containsPoint: Sensor cursorPoint) 
  26.                             ifFalse: [Display flash: frame.
  27.                                         self markerOff]
  28.                             ifTrue: [(selection = 0) 
  29.                                 ifTrue:[self markerOn: self topLeft]]]
  30.                     ifTrue:     [(frame containsPoint: Sensor cursorPoint) 
  31.                             ifTrue: [done _ (frame containsPoint: 
  32.                                                     Sensor waitNoButton)]]
  33.                 ]
  34.         ].
  35.     ^selection! !
  36.  
  37.  
  38. !PopUpNotifier methodsFor: 'private'!
  39.  
  40. fixString: aString
  41.     "Return a string that is wrapped before it exceeds the width of Heading"
  42.  
  43.     | begin cr  string width size end length |
  44.  
  45.     cr _ '
  46. '.
  47.     begin _ 1.
  48.     string _ Heading, cr, cr, Boundary.
  49.     length _ 0.
  50.     end _ begin.
  51.     width _ (Heading size) - ( 2 * (Boundary size)).
  52.     size _ aString size.
  53.  
  54.     [end > size] whileFalse: [
  55.         end _ aString findString: ' ' startingAt: end.
  56.         ((end = 0) | (end = size) | ((end - begin) >= width))
  57.             ifTrue: [(end = 0) ifTrue: [end _ size].
  58.                     string _ string, (aString copyFrom: begin to: end), 
  59.                                 Boundary, cr, Boundary.
  60.                     begin _ end + 1.
  61.                     ].
  62.         end _ end + 1.
  63.         ].
  64.     ^string!
  65.  
  66. labels: aString textStyle: aTextStyle lines: anArray
  67.  
  68.     | para | 
  69.  
  70.     labelString _ self fixString: aString.
  71.     textStyle _ aTextStyle alignment: 0.
  72.     ^super labels: labelString textStyle: textStyle lines: #(1)! !
  73.  
  74. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
  75.  
  76. PopUpNotifier class
  77.     instanceVariableNames: ''!
  78.  
  79.  
  80. !PopUpNotifier class methodsFor: 'class initialization'!
  81.  
  82. initialize
  83.     "Create the default heading"
  84.     "PopUpNotifier initialize"
  85.  
  86.     Boundary _ '   '.    
  87.     Heading _ Boundary,'Click middle button when done',Boundary.! !
  88.  
  89.  
  90. !PopUpNotifier class methodsFor: 'instance creation'!
  91.  
  92. message: aString
  93.     "Create a PopUpMenu with standard heading, and start it up"
  94.  
  95.  
  96.     ^(PopUpNotifier labels: aString) startUp: #yellowButton! !
  97.  
  98.  
  99. PopUpNotifier initialize!
  100.